---
category: Function
created: '2020-05-12'
title: Flip the arguments of a function
---

**JavaScript version**

```js flip.js
// Reverse the order of arguments
const flip =
    (fn) =>
    (...args) =>
        fn(...args.reverse());

// For binary functions
const flip = (fn) => (b, a) => fn(a, b);

// Or for curried functions
const flip = (fn) => (b) => (a) => fn(a)(b);
```

**Examples**

```js examples.js
const isParent = (parent, child) => parent.children.includes(child);
const isChild = flip(isParent);
```
